package com.hcy.asyncfiledownload.ordermodule.controller;

import com.hcy.asyncfiledownload.common.dto.OrderExportDto;
import com.hcy.asyncfiledownload.common.entry.ExportRecord;
import com.hcy.asyncfiledownload.mockdatabase.MockData;
import com.hcy.asyncfiledownload.ordermodule.service.IOrderService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author huchenying
 * @Date 2022/9/5 18:17
 * @Description 接收前端发出的文件导出请求
 */
@RestController
@RequestMapping("/order")
@Log4j2
public class OrderController {

    @Autowired
    IOrderService orderService;

    @GetMapping("/getExportList")
    public List<ExportRecord> getExportList(){
        return MockData.getExportRecords();
    }


    @PostMapping("/export")
    public String export(@RequestBody OrderExportDto request){
        log.info("export start param -> {}", request);
        orderService.handlerOrderExport(request);
        return "OK";
    }

}
